package com.zonta.finance.serivce.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zonta.finance.common.exception.BizException;
import com.zonta.finance.domain.po.MemberBindWxOpenid;
import com.zonta.finance.mapper.MemberBindWxOpenidMapper;
import com.zonta.finance.serivce.IMemberBindWxOpenidService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表绑定微信openid表 服务实现类
 * </p>
 *
 * @author zonta
 * @since 2024-07-23
 */
@Service
public class MemberBindWxOpenidServiceImpl extends ServiceImpl<MemberBindWxOpenidMapper, MemberBindWxOpenid> implements IMemberBindWxOpenidService {

    @Override
    public void register(String appId, String openId, long id) {
        MemberBindWxOpenid memberBindWxOpenId = new MemberBindWxOpenid();
        memberBindWxOpenId.setAppId(appId);
        memberBindWxOpenId.setOpenId(openId);
        memberBindWxOpenId.setMemberId(id);
        memberBindWxOpenId.initDefault();
        if (!save(memberBindWxOpenId)) {
            throw new BizException("注册微信用户失败");
        }
    }
}
